/* type Width = number | string;
let width: Width = 100;
width = '100%';

type Color = 'red' | 'blue' | 'green';
let color1: Color = 'red';
let color2: Color = 'blue';
let color3: Color = 'green';

type Student = {
  name: string,
  score: number
}

type Teacher = {
  name: string,
  age: number,
  subject: string
}

type Person = Student | Teacher

const person1: Person = { name: 'John', score: 100 };
const person2: Person = { name: 'Jane', age: 35, subject: 'Math' };
const person3: Person = { name: 'Tom', score: 90, age: 40, subject: 'Science' };
// const person4: Person = { name: "jack" };

console.log(person3.name);
console.log((person3 as Teacher).age);
console.log((person3 as Student).score); */

type Color = "黑色" | "白色" | "褐色" | "花色"
type Breed = "英短" | "中华田园猫" | "暹罗猫" | "孟买猫"

type Cat = {
  name: string,
  age: number,
  gender: "公" | "母",
  color?: Color,
  breed?: Breed,
}

const cat: Cat = {
  name: "Tom",
  age: 3,
  gender: "公",
  color: "花色",
  breed: "中华田园猫",
}
cat.breed = "暹罗猫";

function getCat() { 
  if (Math.random() > 0.5) {
    return cat;
  }
  else if (Math.random() > 0.8) { 
    return {
      name: "Tom",
      age: 3,
      gender: "公",
      color: "花色",
      breed: "中华田园猫",
    }
  }
}